function [output]=colorfeaturegrouping(Inputimage)
image1=double(Inputimage);
Row=size(Inputimage,1);
Coloumn=size(Inputimage,2);

% extract skin
YCbCrimage1=rgb2ycbcr(image1);
Cr=YCbCrimage1(:,:,3);
[SkinIndexRow,SkinIndexCol] =find(10<Cr & Cr<45);

%finding the range for y ,cb ,cr part of the image
%calculating minimum value for the range

YCbCrimage=rgb2ycbcr(Inputimage);
Crpart=YCbCrimage(:,:,3);
ypart=YCbCrimage(:,:,1);
cbpart=YCbCrimage(:,:,2);

ymin=ypart(SkinIndexRow(1),SkinIndexCol(1));
cbmin=cbpart(SkinIndexRow(1),SkinIndexCol(1));
crmin=Crpart(SkinIndexRow(1),SkinIndexCol(1));
for i=1:length(SkinIndexRow)
    if (ymin>ypart(SkinIndexRow(i),SkinIndexCol(i)))
        ymin=ypart(SkinIndexRow(i),SkinIndexCol(i));
    end
    if (cbmin>cbpart(SkinIndexRow(i),SkinIndexCol(i)))
        cbmin=cbpart(SkinIndexRow(i),SkinIndexCol(i));
    end
    if (crmin>Crpart(SkinIndexRow(i),SkinIndexCol(i)))
        crmin=Crpart(SkinIndexRow(i),SkinIndexCol(i));
    end
end

%calculating maximum value for the range
ymax=ypart(SkinIndexRow(1),SkinIndexCol(1));
cbmax=cbpart(SkinIndexRow(1),SkinIndexCol(1));
crmax=Crpart(SkinIndexRow(1),SkinIndexCol(1));
for i=1:length(SkinIndexRow)
   
    if (ymax<ypart(SkinIndexRow(i),SkinIndexCol(i)))
        ymax=ypart(SkinIndexRow(i),SkinIndexCol(i));
    end
    if (cbmax<cbpart(SkinIndexRow(i),SkinIndexCol(i)))
        cbmax=cbpart(SkinIndexRow(i),SkinIndexCol(i));
    end
    if (crmax<Crpart(SkinIndexRow(i),SkinIndexCol(i)))
        crmax=Crpart(SkinIndexRow(i),SkinIndexCol(i));
    end
end

%finding average for y cb cr

ysum=0;
yavg=0;
for i=1:length(SkinIndexRow)   
    yvalues(i)=ypart(SkinIndexRow(i),SkinIndexCol(i));
end
ysum=sum(yvalues);
yavg =ysum/length(SkinIndexRow);

cbsum=0;
cbavg=0;
for i=1:length(SkinIndexRow)   
    cbvalues(i)=cbpart(SkinIndexRow(i),SkinIndexCol(i));
end
cbsum=sum(cbvalues);
cbavg =cbsum/length(SkinIndexRow);

crsum=0;
cravg=0;
for i=1:length(SkinIndexRow)   
    crvalues(i)=Crpart(SkinIndexRow(i),SkinIndexCol(i));
end
crsum=sum(crvalues);
cravg =crsum/length(SkinIndexRow);

%displaying minimum value of y cb and cr
%ymin
%cbmin
%crmin

%displaying maximum value for the range
%ymax
%cbmax
%crmax

%displaying maximum value for the range
%yavg
%cbavg
%cravg

%grouping
VALUES=[ymin cbmin ymax cbmax crmax yavg cbavg cravg];
MIN=[22 82 198 124 160 110 103 141];
MAX=[59 115 230 156 172 180 124 159];

n = sum(MIN <= VALUES) + sum(VALUES <= MAX);

if n >=16
    output='CA';
else
    output='BA';
end
output